package com.ruoyi.web.controller.warning;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.warning.domain.entity.WarningConfigurationRuleRelation;
import com.ruoyi.warning.service.IWarningConfigurationRuleRelationService;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * <p>
 * 告警配置与规则关系表 前端控制器
 * </p>
 *
 * @author chenhc
 * @since 2025-04-29
 */
@RestController
@RequestMapping("/ConfigurationRuleRelation")
public class WarningConfigurationRuleRelationController {
@Resource
private IWarningConfigurationRuleRelationService relationService;
    @ApiOperation("保存关系")
    //@PreAuthorize("@ss.hasPermi('system:config:export')")
    @PostMapping(value = "/save")
    public R list(List<WarningConfigurationRuleRelation> list)
    {
        LambdaQueryWrapper<WarningConfigurationRuleRelation> wrapper = new LambdaQueryWrapper<WarningConfigurationRuleRelation>()
                .eq(WarningConfigurationRuleRelation::getConfigurationId,list.get(0).getConfigurationId());
        relationService.remove(wrapper);
        relationService.saveBatch(list);
        return R.ok();
    }
}
